<%--
  Created by IntelliJ IDEA.
  User: Shinelon
  Date: 2020/12/2
  Time: 10:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<link rel="stylesheet" href="${pageContext.request.contextPath}/style/assets/css/style.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/style/assets/css/responsive.css">
<script src="${pageContext.request.contextPath}/style/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/style/layui/css/layui.css">
<script src="${pageContext.request.contextPath}/style/layui/layui.js"></script>
<html>
<head>
    <title>前台管理</title>
    <script>
        //预备函数
        $(function () {
                //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
                layui.use(['element','layer','form','laydate'], function () {
                    var layer2=layui.layer;
                    var layer1 = layui.layer;
                    var element = layui.element;
                    var layer = layui.layer;
                    var form = layui.form;
                    var laydate = layui.laydate;
                    var syAndManDate="";
                    var flage=false;
                    var initLayDate="";
                    form.render();
                    //显示所有的房间类型到选项卡
                    showroom();

                    //显示所有的房间号
                    function showroom(){
                        $.ajax({
                            url: '/Hotel/qiantai/selectByTID',
                            data: {},
                            async: false,
                            success: function (data) {
                                console.log(data)
                                console.log(data.length)
                               $("#father").find("li").remove()
                                for (var j = 0; j < data.length; j++) {
                                    var li = $("#temp").clone();
                                    li.attr("id", "");
                                    li.attr("style", "");
                                    li.find(".rname").html(data[j].roomcode);
                                    li.find(".xfstatus").html(data[j].xfstatus)
                                    li.find(".showtname").html(data[j].tname);
                                    li.find(".yj").html(data[j].yj);
                                    li.find(".typeid").html(data[j].typeid);
                                    li.find(".tname").html(data[j].tname);
                                    li.find(".orderid").html(data[j].orderid);
                                    li.find(".money").html(data[j].money);
                                    li.find(".yj").html(data[j].yj);
                                    li.find(".rzstatus").html(data[j].rzstatus)
                                    li.find(".ruzhuid").html(data[j].ruzhuid);
                                    // var status = li.find(".status").html(d[i].status);
                                    if (data[j].status == 0 ) {
                                        li.find(".status").css({"backgroundColor": "#5FB878"})
                                        li.find("input[value='可用']")
                                        li.find("input[value='换房']").hide()
                                        li.find("input[value='退房']").hide()
                                        li.find("input[value='打扫']").hide()
                                        li.find("input[value='续房']").hide()
                                    } else if (data[j].status == 1 && data[j].hfstatus == 0 && data[j].xfstatus == 0) {
                                        li.find(".status").css({"backgroundColor": "pink"})
                                        li.find(".date2").parent().show();
                                        li.find(".date1").parent().show();
                                        li.find(".name").parent().show();
                                        li.find(".tel").parent().show();
                                        li.find(".name").html(data[j].name);
                                        li.find(".tel").html(data[j].tel)
                                        li.find(".date1").html(data[j].rzdate1)
                                        li.find(".date2").html(data[j].leavedate1)
                                        li.find("input[value='可用']").hide();
                                        li.find("input[value='续房']");
                                        let date = setDate();
                                        if(date == data[j].leavedate1){
                                            li.find("input[value='换房']").hide();
                                        }else {
                                            li.find("input[value='换房']");}
                                        li.find("input[value='退房']")
                                        li.find("input[value='打扫']").hide()
                                        li.find("input[value='续房']");
                                    }else if (data[j].status == 2 ) {
                                        li.find(".status").css({"backgroundColor": "orange"})
                                        li.find("input[value='可用']").hide()
                                        li.find("input[value='换房']").hide()
                                        li.find("input[value='退房']").hide()
                                        li.find("input[value='打扫']")
                                        li.find("input[value='续房']").hide()
                                    } else if (data[j].status == 1 && data[j].hfstatus == 1 && data[j].xfstatus == 0 ) {
                                        //换房
                                        li.find(".status").css({"backgroundColor": "pink"})
                                        $.ajax({
                                            url:'/Hotel/qiantai/selectchangeroom',
                                            data:{ruzhuid:li.find(".ruzhuid").html()},
                                            async:false,
                                            dateType: 'json',
                                            success:function (d) {
                                                console.log(d)
                                                li.find(".date2").parent().show();
                                                li.find(".name").parent().show();
                                                li.find(".tel").parent().show();
                                                li.find(".ruzhuid").html(d[0].ruzhuid);
                                                li.find(".name").html(d[0].name);
                                                li.find(".tel").html(d[0].tel);
                                                li.find(".oldroom").parent().show();
                                                li.find(".oldroom").html(d[0].oldroomid)
                                                li.find(".date3").parent().show();
                                                li.find(".date3").html(d[0].time)
                                                li.find(".date2").html(d[0].leavedate1)
                                                li.find("input[value='可用']").hide()
                                                li.find("input[value='换房']")
                                                li.find("input[value='退房']")
                                                li.find("input[value='打扫']").hide()
                                                li.find("input[value='续房']")
                                            }
                                        })
                                    }else if (data[j].status == 1 && data[j].xfstatus == 1 && data[j].hfstatus == 1) {
                                        //续房
                                        li.find(".status").css({"backgroundColor": "pink"})
                                        $.ajax({
                                            url:'/Hotel/qiantai/selectxufang',
                                            data:{ruzhuid:li.find(".ruzhuid").html()},
                                            async:false,
                                            dateType: 'json',
                                            success:function (d) {
                                                console.log(d)
                                                li.find(".ruzhuid").html(d[0].ruzhuid);
                                                li.find(".name").html(d[0].name);
                                                li.find(".tel").html(d[0].tel);
                                                li.find(".xfdate").parent().show();
                                                li.find(".date2").parent().show();
                                                li.find(".date1").parent().show();
                                                li.find(".name").parent().show();
                                                li.find(".tel").parent().show();
                                                li.find(".xfdate").html(d[0].endtime);
                                                li.find(".date2").html(d[0].leavedate1);
                                                li.find(".date1").html(d[0].rzdate1);
                                                li.find("input[value='可用']").hide();
                                                li.find("input[value='续房']").hide();
                                                let date = setDate();
                                                if(date == d[0].endtime){
                                                    li.find("input[value='换房']").hide();
                                                }else {
                                                li.find("input[value='换房']");}
                                                li.find("input[value='退房']");
                                                li.find("input[value='打扫']").hide();
                                            }
                                        })
                                    }
                                    else if (data[j].status == 1 && data[j].xfstatus == 1 && data[j].hfstatus == 0) {
                                        //续房
                                        li.find(".status").css({"backgroundColor": "pink"})
                                        $.ajax({
                                            url:'/Hotel/qiantai/selectxufang',
                                            data:{ruzhuid:li.find(".ruzhuid").html()},
                                            async:false,
                                            dateType: 'json',
                                            success:function (d) {
                                                console.log(d)
                                                li.find(".ruzhuid").html(d[0].ruzhuid);
                                                li.find(".name").html(d[0].name);
                                                li.find(".tel").html(d[0].tel);
                                                li.find(".xfdate").parent().show();
                                                li.find(".date2").parent().show();
                                                li.find(".date1").parent().show();
                                                li.find(".name").parent().show();
                                                li.find(".tel").parent().show();
                                                li.find(".xfdate").html(d[0].endtime);
                                                li.find(".date2").html(d[0].leavedate1);
                                                li.find(".date1").html(d[0].rzdate1);
                                                li.find("input[value='可用']").hide();
                                                let date = setDate();
                                                if(date == d[0].endtime){
                                                    li.find("input[value='换房']").hide();
                                                }else {
                                                    li.find("input[value='换房']");}
                                                li.find("input[value='退房']");
                                                li.find("input[value='打扫']").hide();
                                                li.find("input[value='续房']").hide();
                                            }
                                        })
                                    }
                                    $("#father").append(li);
                                }
                            },
                            error: function () {
                                alert("失败")
                            }
                        })
                    }
                    //刷新页面
                    $("#shuaxin").click(function () {
                        showroom();
                    })
                    //退房
                    $("#father").on('click','input[value="退房"]',function () {
                        var f1 = $(this).parent().parent().parent();
                        var id = f1.find(".typeid").html();
                        var tname = f1.find(".tname").html();
                        var orderid = f1.find(".orderid").html();
                        var ruzhuid = f1.find(".ruzhuid").html();
                        var roomcode = f1.find(".rname").html();
                        var yj = f1.find(".yj").html();
                        var xf = f1.find(".xfstatus").html();
                        var leave = '';
                        if(xf == 1){
                            $.ajax({
                                url:'/Hotel/qiantai/selectxufang',
                                data:{ruzhuid:ruzhuid},
                                async:false,
                                dateType: 'json',
                                success:function (d) {
                                    leave = d[0].endtime;
                                }
                            })
                        }else {
                            leave = f1.find(".date2").html();
                        }
                        let date = setDate();
                        var ndatehour = new Date().getHours();
                        var leave1 = new Date(leave).getTime();
                        var ndate = new Date(date).getTime();
                        var d = (Number(leave1) - Number(ndate)) / (1000 * 60 * 60 * 24);
                        // console.log("天数"+d)
                        var money = f1.find(".money").html();d
                        $("#syday").html(d);
                        $("#jiage").html(money);
                        $("#leave").html(leave);
                        var sum ='';
                        if( date == leave){
                            console.log(111)
                            sum = 0;
                            d = 0 ;

                        }else {
                            if (ndatehour > 14) {
                                $("#istime").attr("checked", true);
                                sum = (Number(d) - 1) * Number(money) + (Number(money) * 0.5);
                            } else {
                                $("#istime").attr("checked", false);
                                sum = Number(d) * Number(money);
                            }
                        }
                        layer.open({
                            title:'退房信息',
                            type:1,
                            offset:'0px',
                            content:$("#tuifangdiv"),
                            area:['550px','450px'],
                            success:function () {
                                form.val('msg', {
                                    "orderid":orderid,
                                    "outdate":date,
                                    "tsmoney":sum,
                                    "ruzhuid":ruzhuid,
                                    "roomcode":roomcode,
                                    "tsyj":yj,
                                });
                            }
                        })
                        form.on('submit(add)',function (data) {
                            console.log(data);
                            $.ajax({
                                url:"/Hotel/qiantai/addtuifang",
                                data:data.field,
                                success:function(d){
                                    layer.alert("退房成功！");
                                    layer.closeAll();
                                    showroom(father,id);
                                },
                                error:function () {
                                    layer.closeAll();
                                    alert("操作失败");
                                }
                            })
                            return false;
                        })
                    })
                    //打扫后恢复空闲
                    $("#father").on('click','input[value="打扫"]',function () {
                        var f1 = $(this).parent().parent().parent();
                        var id = f1.find(".typeid").html();
                        var roomcode = f1.find(".rname").html();
                        console.log(roomcode);
                        $.ajax({
                            url:'/Hotel/chuku/clean',
                            data:{roomcode:roomcode},
                            async:false,
                            success:function () {
                            },error:function () {
                                alert("错误")
                            }
                        })
                        $.ajax({
                            url:"/Hotel/qiantai/dasao",
                            data:{roomcode:roomcode},
                            async:false,
                            success:function(d){
                                layer.open({
                                    type:0,
                                    offset:'10px',
                                    content:'打扫成功！库存减少'
                                })
                                showroom(father,id);
                            },
                            error:function () {
                                layer.closeAll();
                                alert("操作失败");
                            }
                        })
                    })
                    //换房
                    $("#father").on('click','input[value="换房"]',function () {
                        var f1 = $(this).parent().parent().parent();
                        var id = f1.find(".typeid").html();
                        var ruzhuid = f1.find(".ruzhuid").html();
                        var roomcode = f1.find(".rname").html();
                        let date = setDate();
                        $.ajax({
                            url:"/Hotel/qiantai/changecount",
                            data:{ruzhuid:ruzhuid},
                            async:false,
                            success:function (d) {
                               if( d >= 2){
                                   layer.open({
                                       content:'最多换2次',
                                       offset:'0px',
                                   })
                               }else {
                                   $.ajax({
                                       url:"/Hotel/qiantai/selectbyky",
                                       data:{typeid:id},
                                       async:false,
                                       success:function(data){
                                           console.log(data)
                                           $("#kyroom").empty();
                                           var option = '';
                                           for(var i = 0 ; i < data.length; i++){
                                               option += '<option value="'+data[i].roomcode+'">'+data[i].roomcode+'</option>'
                                           }
                                           $("#kyroom").append(option);
                                           form.render();
                                       },
                                       error:function () {
                                           layer.closeAll();
                                           alert("操作失败");
                                       }
                                   })
                                   form.render('select');
                                   layer.open({
                                       title:'选择房间',
                                       type:1,
                                       offset:'0px',
                                       content:$("#huanfangdiv"),
                                       area:['350px','340px'],
                                       success:function () {
                                           form.val('msg1', {
                                               // "orderid":orderid,
                                               // "outdate":date,
                                               // "tsmoney":sum,
                                               "ruzhuid":ruzhuid,
                                               "oldroomid":roomcode,
                                               "time":date
                                           });
                                       }
                                   })
                                   form.on('submit(change)',function (data) {
                                       $.ajax({
                                           url:"/Hotel/qiantai/changeroom",
                                           data:data.field,
                                           success:function(d){
                                               layer.closeAll();
                                               showroom();
                                               // f1.find(".ruzhuid").html(ruzhuid);
                                           },
                                           error:function () {
                                               layer.closeAll();
                                               alert("操作失败");
                                           }
                                       })
                                       return false;
                                   })
                               }
                            },
                            error:function (d) {
                                alert("错误")
                            }
                        })

                    })
                    //可入住
                    $("#father").on('click','input[value="可用"]',function () {
                        layer.open({
                            type:0,
                            offset:'10px',
                            content:'抱歉！目前只支持网上下单'
                        })
                    })
                    //续房
                    $("#father").on('click','input[value="续房"]',function () {
                        var f1 = $(this).parent().parent().parent();
                        var id = f1.find(".typeid").html();
                        var xuzhuDate = f1.find(".date2").html();
                        var money = f1.find(".money").html();
                        var name = f1.find(".name").html();
                        var tel = f1.find(".tel").html();
                        var ruzhuid = f1.find(".ruzhuid").html();
                        $("#name").val(name);
                        $("#tel").val(tel);
                        $("#price").val(money)
                        $("#rzdate").val(xuzhuDate)
                        var price = $("#price").val();
                        console.log(xuzhuDate);
                        $.ajax({
                            url:"${pageContext.request.contextPath}/findTypeById",
                            type:"post",
                            data:{typeid:id},
                            dataType:"json",
                            async:false,
                            success:function (f) {
                                console.log(f)
                                syAndManDate=f.orderMess;
                                console.log(syAndManDate)
                                if(syAndManDate==undefined){
                                    initLayDate.getRiLi('',xuzhuDate);
                                }else{
                                    //
                                    syDateAndCount=syAndManDate.srDate;
                                    //alert(JSON.stringify(syDateAndCount));
                                    //alert("已满的时间是:"+syAndManDate.manDate);
                                    initLayDate.getRiLi(syAndManDate.manDate,xuzhuDate);
                                    //获取日期  以及他们对应的剩余的房间数
                                }
                            }
                        })
                        layer1.open({
                            type: 1
                            , title: '续房['+f1.find(".rname").html()+']' //不显示标题栏
                            , closeBtn: 1
                            , resize: false
                            , area: ['680px', '344px']
                            , offset: '0px'
                            , shade: 0.8
                            , fixed: true
                            , id: 'LAY_layuipr1o' //设定一个id，防止重复弹出
                            , btnAlign: 'c'
                            , moveType: 1 //拖拽模式，0或者1
                            , content: $("#order")
                            ,success:function () {
                                $("#tips").html('');
                                form.val('add', {
                                    "rzdate":xuzhuDate,
                                    "begintime":xuzhuDate,
                                    "ruzhuid":ruzhuid,
                                });
                                var order = new Object();
                                order.roomtype=id;
                                form.on('submit(search)',function (data) {
                                    order.rzdate = $("#rzdate").val();
                                    order.leavedate=$("#leavedate").val();
                                    $("#tips").empty();
                                    synum(order);
                                    return false
                                })
                            }
                            ,end:function () {
                            }
                        })
                        form.on('submit(add)',function (data) {
                            $.ajax({
                                    url:'${pageContext.request.contextPath}/qiantai/addxufang?roomtype='+id,
                                    data:data.field,
                                    success:function (f) {
                                        if (f == 1) {
                                            layer2.open({
                                                type: 0
                                                , area: ['200px', '200px']
                                                , offset: '0px'
                                                , fixed: true
                                                ,closeBtn: false
                                                , id: 'LAY_layuipro112' //设定一个id，防止重复弹出
                                                , btn: ['关闭']
                                                , btnAlign: 'c'
                                                , moveType: 1 //拖拽模式，0或者1
                                                , content: '续房成功'
                                                , success: function (layero) {
                                                    var btn = layero.find('.layui-layer-btn');
                                                    btn.find('.layui-layer-btn0').click(function () {
                                                        layer.closeAll();
                                                        showroom();
                                                        $("#addform")[0].reset();
                                                        // reset();
                                                    })
                                                }
                                            })
                                        } else if (f == 0) {
                                            layer2.open({
                                                type: 0
                                                , area: ['200px', '200px']
                                                , offset: '0px'
                                                , fixed: true
                                                , id: 'LAY_layuipro11' //设定一个id，防止重复弹出
                                                , btn: ['重新数量']
                                                , btnAlign: 'c'
                                                ,closeBtn:0
                                                , moveType: 1 //拖拽模式，0或者1
                                                , content: '房间数量不足'
                                                , success: function (layero) {
                                                    var btn = layero.find('.layui-layer-btn');
                                                    btn.find('.layui-layer-btn0').click(function () {
                                                        $("#rcount").val("");
                                                        total();
                                                    })
                                                }
                                            })
                                        }
                                    }
                                })
                            return false;
                        })
                    })
                    //计算这段时间段内可以预定的房间数量
                    function synum(obj) {
                        $("#tips").empty();
                        $.ajax({
                            url:'/Hotel/sysum',
                            data:obj,
                            async:false,
                            success:function (d) {
                                // alert(d);
                                $("#tips").html("该时间段可用的房间数量为"+d+"间")
                            },
                            error:function () {
                                $("#tips").html("请选择入住和离开时间")
                            }

                        })

                    }
                    //改变时间
                    function changeTime(times){
                        var time=times.split("-");
                        var year=time[0];
                        var month=time[1];
                        if(Number(month)<10){
                            //将数据库中传过来的01变为1
                            month=Number(month);
                            //alert(Number(month));
                        }
                        var day=time[2];
                        if(Number(day)<10){
                            //将数据库中传过来的01变为1
                            day=Number(day);
                        }
                        var item=year+"-"+month+"-"+day;
                        return item;
                    }
                    //计算总价的函数
                    function total() {
                        var day = $("#d").val();
                        console.log("day::"+day);
                        var num = $("#rcount").val();
                        console.log("num::"+num);
                        var price = $("#price").val();
                        console.log("price::"+price);
                        var sum = Number(day)*Number(price)*Number(num);
                        $("#sum").val(sum);
                        $("#xfprice").val(sum);
                    }
                    //设置时间给文本框
                    function setValforDate(value,xuzhuDate){
                        var dateTime = value.split('~');
                        // var startTime = dateTime[0].replace(/-/g, "/");
                        var startTime = xuzhuDate.replace(/-/g, "/")
                        var endTime = dateTime[0].replace(/-/g, "/");
                        var startTime1 = dateTime[0];
                        var endTime1 = dateTime[0];
                        var s = Date.parse(startTime);
                        var e = new Date(endTime).getTime();
                        //计算两个时间间隔天数
                        var d = (Number(e) - Number(s)) / (1000 * 60 * 60 * 24);
                        $("#d").val(d);
                        $("#tian").html(d);
                        if (d > 30) {
                            layer2.open({
                                type:0
                                ,area: ['200px', '200px']
                                , offset: '200px'
                                , fixed: true
                                , id: 'LAY_layuipro11' //设定一个id，防止重复弹出
                                , btn: ['重新选择']
                                , btnAlign: 'c'
                                ,closeBtn:0
                                , moveType: 1 //拖拽模式，0或者1
                                , content: '最多选择30天'
                                ,success: function(layero){
                                    console.log(syAndManDate)
                                    var btn = layero.find('.layui-layer-btn');
                                    btn.find('.layui-layer-btn0').click(function () {
                                        if(syAndManDate==undefined){
                                            initLayDate.getRiLi('',xuzhuDate);
                                        }else{
                                            //
                                            syDateAndCount=syAndManDate.srDate;
                                            //alert(JSON.stringify(syDateAndCount));
                                            //alert("已满的时间是:"+syAndManDate.manDate);
                                            initLayDate.getRiLi(syAndManDate.manDate,xuzhuDate);
                                            //获取日期  以及他们对应的剩余的房间数
                                        }
                                        $("#rzdate").val(xuzhuDate);
                                        $("#leavedate").val('');
                                        $("#endtime").val('');
                                        $("#sum").val(0);
                                        $("#tips").html('');
                                    })
                                }
                            })
                        }
                        if(d<1){
                            layer2.open({
                                type:0
                                ,area: ['200px', '200px']
                                , offset: '200px'
                                , fixed: true
                                , id: 'LAY_layuipro111' //设定一个id，防止重复弹出
                                , btn: ['重新选择']
                                , btnAlign: 'c'
                                ,closeBtn:0
                                , moveType: 1 //拖拽模式，0或者1
                                , content: '最少选择一天'
                                ,success: function(layero){
                                    var btn = layero.find('.layui-layer-btn');
                                    btn.find('.layui-layer-btn0').click(function () {
                                        if(syAndManDate==undefined){
                                            initLayDate.getRiLi('',xuzhuDate);
                                        }else{
                                            //
                                            syDateAndCount=syAndManDate.srDate;
                                            //alert(JSON.stringify(syDateAndCount));
                                            //alert("已满的时间是:"+syAndManDate.manDate);
                                            initLayDate.getRiLi(syAndManDate.manDate,xuzhuDate);
                                            //获取日期  以及他们对应的剩余的房间数
                                        }
                                        $("#rzdate").val(xuzhuDate);
                                        $("#leavedate").val('');
                                        $("#endtime").val('');
                                        $("#sum").val(0);
                                        $("#tips").html('');
                                    })
                                }
                            })
                        }
                        $("#rzdate").val(xuzhuDate);
                        $("#leavedate").val($.trim(endTime1));
                        $("#endtime").val($.trim(endTime1));
                        $("#tips").html('');
                        total();
                    }
                    //某个时间段室内是否含有这个时间如果含有就返回true 否则就false
                    function  isDuringDate(beginDateStr, endDateStr,dateStr) {
                        var curDate = new Date(dateStr),
                            beginDate = new Date(beginDateStr),
                            endDate = new Date(endDateStr);
                        if (curDate >= beginDate && curDate < endDate) {
                            return true;
                        }
                        return false;
                    }
                    initLayDate= {
                        getRiLi:function(removedate,xuzhuDate){
                            let date = setDate();
                            var leave1 = new Date(xuzhuDate).getTime();
                            var ndate = new Date(date).getTime();
                            var d = (Number(leave1) - Number(ndate)) / (1000 * 60 * 60 * 24)+1;
                            var tt=new Object();
                            if(removedate=="") {
                                $("#test3").empty();
                                laydate.render({
                                    elem: '#test3',
                                    min: d,
                                    position: 'static',
                                    mark: tt,
                                    // range: '~',
                                    showBottom:false,
                                    change:function (value) {
                                        //给日期赋值
                                        setValforDate(value,xuzhuDate);
                                    }
                                });
                            }else {
                                //alert(removedate);
                                $("#test3").empty();
                                for(var i=0;i<removedate.length;i++){
                                    var sdate = removedate[i]; //记录时间
                                    var date_array = sdate.split("-");
                                    var date_day = date_array[2]; //取日期的天比如2017-09-11取11
                                    tt[removedate[i]]='<span style="color:#666;font-size: 14px;"><i class="layui-icon layui-icon-heart-fill" style="color:rgba(238, 143, 92, 0.8); position:absolute; left: 5px;font-size: 28px;z-index:-1;"></i>' + Number(date_day) + '</span>';
                                    //初始日期控件
                                }
                                laydate.render({
                                    elem: '#test3',
                                    min: d,
                                    position: 'static',
                                    mark: tt,
                                    // range: '~',
                                    showBottom:false,
                                    ready: function (value) {
                                        var mm = value.year + '-' + value.month + '-' + value.date;
                                        $.each(removedate, function (index, item) {
                                            var item=changeTime(item);
                                            //$('.layui-laydate table tbody').find('[lay-ymd="' + item + '"]').addClass('laydate-disabled');
                                        })
                                    },
                                    change: function (value) {
                                        flage=false;
                                        var dateTime = value.split('~');
                                        // var startTime = dateTime[0].replace(/-/g,"/");
                                        var startTime = xuzhuDate.replace(/-/g,"/");
                                        var endTime = dateTime[0].replace(/-/g,"/");
                                        var s=Date.parse(startTime);
                                        var e = new Date(endTime).getTime();
                                        //如果选择的时间段之内有房间已满的情况就不允许选择
                                        $.each(removedate, function (index, item) {
                                            var disabletime=item.replace(/-/g,"/");
                                            var f=isDuringDate(s,e,disabletime);
                                            if(f){
                                                flage=true;
                                            }
                                            //var item=changeTime(item);
                                            //$('.layui-laydate table tbody').find('[lay-ymd="' + item + '"]').addClass('laydate-disabled');
                                        })
                                        console.log(flage)
                                        if(!flage){
                                            setValforDate(value,xuzhuDate);
                                        }else{
                                            layer2.open({
                                                type:0
                                                ,area: ['200px', '200px']
                                                , offset: '200px'
                                                , fixed: true
                                                , id: 'LAY_layuipro11' //设定一个id，防止重复弹出
                                                , btn: ['重新选择']
                                                , btnAlign: 'c'
                                                ,closeBtn:0
                                                , moveType: 1 //拖拽模式，0或者1
                                                , content: '当前时间段之内有的房间已满'
                                                ,success: function(layero){
                                                    var btn = layero.find('.layui-layer-btn');
                                                    btn.find('.layui-layer-btn0').click(function () {
                                                        initLayDate.getRiLi(syAndManDate.manDate,xuzhuDate);
                                                        $("#rzdate").val(xuzhuDate);
                                                        $("#leavedate").val('');
                                                        $("#sum").val(0);
                                                    })
                                                }
                                            })
                                        }
                                    }
                                });
                            }
                        }
                    }

                }); //layui函数作用域结束

            //获取当前的年月日
            function setDate(){
                var now = new Date();
                var year = now.getFullYear(); //年
                var month = now.getMonth() + 1; //月
                // var temp = new Date(year, month, 0); //当前月最后一天
                month = month >= 10 ? month : "0" + month;
                var day = now.getDate(); //日
                day = day >= 10 ? day : "0" + day;
                // var v_from = year + "-" + month + "-01";
                var v_to = year + "-" + month + "-" + day;
                return v_to;
            }
        })//预备函数作用域结束
    </script>
</head>
<body>
<div>
    <section class="best-room" >
        <div class="container">
            <div class="title-main" style="position: relative;left:0px;top: -40px">
                <div style="height: 30px">
                    <div style="float: right;"><input type="button" class="layui-btn layui-btn-sm" value="刷新" id="shuaxin"/></div>
                    <div style="background-color: #5FB878;height: 20px;width: 30px;float: left"></div>
                    <div style="float: left">:空闲</div>
                    <div style="background-color: pink;height: 20px;width: 30px;float: left"></div>
                    <div style="float: left">:入住</div>
                    <div style="background-color: orange;height: 20px;width: 30px;float: left"></div>
                    <div style="float: left">:待打扫</div>
                </div>
            </div>
            <div class="best-room-carousel" >
<%--                <div  style="display: none" class="temp1"></div>--%>
                <ul class="row best-room_ul" id="father">

                </ul>
            </div>
        </div>
    </section>
</div>
<%--li复制模范--%>
<li class="col-lg-2 col-md-2 col-sm-6 col-xs-12 best-room_li" id="temp" style="display: none">
    <div style="border:2px solid rebeccapurple;border-radius: 10px;background: pink" class="status">
        <div >
            <div style="height: 30px;border-bottom: 2px solid rebeccapurple;">
                <span class="showtname" style="font-size: 20px;color: darkslategray;font-family: '楷体"></span>
            </div>
            <div style="height: 30px;border-bottom: 2px solid rebeccapurple" >
                <div class="rname" style="font-size: 20px;margin-left: 60px"></div>
            </div>
        </div>
        <div  style="height: 200px;">
            <div style="display: none" class="typeid">房间类型id</div>
            <div style="display: none" class="tname">房间类型名</div>
            <div style="display: none" class="orderid">订单号</div>
            <div style="display: none" class="money">单价</div>
            <div style="display: none" class="yj">押金</div>
            <div style="display: none" class="ruzhuid">入住id</div>
            <div style="display: none" class="rzstatus">入住id状态</div>
            <div style="display: none" class="xfstatus">是否是续房的</div>
            <div style="width:150px;height: 30px;display: none">姓名：<span class="name"></span></div>
            <div style="width:150px;height: 30px;display: none">电话：<span class="tel"></span></div>
            <div style="width:150px;height: 30px;display: none">原房间：<span class="oldroom"></span></div>
            <div style="width:150px;height: 30px;display: none">换房时间：<span class="date3"></span></div>
            <div style="width:150px;height: 30px;display: none">入住时间：<span class="date1"></span></div>
            <div style="width:150px;height: 30px;display: none">离开时间：<span class="date2"></span></div>
            <div style="width:150px;height: 30px;display: none">续房时间：<span class="xfdate"></span></div>
            <div style="position: absolute;bottom: 10px;left:18px">
                <div class="yj" style="display:none;"></div>
                <input type="button" value="可用" class="layui-btn-sm layui-btn-normal">
                <input type="button" value="换房" class="layui-btn-sm layui-btn-normal">
                <input type="button" value="退房" class="layui-btn-sm layui-btn-normal">
                <input type="button" value="打扫" class="layui-btn-sm layui-btn-normal">
                <input type="button" value="续房" class="layui-btn-sm layui-btn-normal">
            </div>
        </div>
    </div>
</li>
<%--模版end--%>

<%--退房的弹出表单--%>
<div style="display: none;margin-top: 50px;margin-left: 50px" id="tuifangdiv">
    <form class="layui-form layui-form-pane" lay-filter="msg" id="tuifangform">
        <div style="display: none"><input type="text" name="roomid"/></div>
        <div style="display: none"><input type="text" name="rzdate1"/></div>
        <div style="display: none"><input type="text" name="leavedate1"/></div>
        <div style="display: none"><input type="text" name="roomcode"/></div>
        <div class="layui-form-item" style="display:none;">
            <label class="layui-form-label">订单号</label>
            <div class="layui-input-inline">
                <input type="text"  name="orderid" readonly  autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="display:none;">
            <label class="layui-form-label">入住id</label>
            <div class="layui-input-inline">
                <input type="text"  name="ruzhuid" lay-verify="required" readonly autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">退房时间</label>
            <div class="layui-input-inline">
                <input type="text"  name="outdate" lay-verify="required" readonly autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid layui-word-aux" >正常离店日期：<span id="leave"></span></div>
        </div>

        <div class="layui-form-item">
            <div class="layui-form-mid layui-word-aux">是否超过14点:</div>
            <div class="layui-input-inline" style="width: 80px">
                <input type="checkbox" disabled lay-skin="switch" lay-text="是|否" id="istime">
            </div>
            <div class="layui-form-mid layui-word-aux" style="margin-left: 0px">14：00后退50%</div>
        </div>

        <div class="layui-form-item">

            <label class="layui-form-label" >应退金额</label>
            <div class="layui-input-inline" style="width: 50px;margin-right: 0px">
                <input type="text" name="tsmoney"  autocomplete="off" class="layui-input" readonly>
            </div>
            <label class="layui-form-label" style="width: 50px;">元</label>
            <div class="layui-form-mid layui-word-aux" style="margin-left: 20px"><span id="jiage"></span>/天 还剩<span id="syday"></span>天</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" >押金</label>
            <div class="layui-input-inline" style="width: 50px;margin-right: 0px">
                <input type="text" name="tsyj"  autocomplete="off" class="layui-input" readonly>
            </div>
            <label class="layui-form-label" style="width: 50px;">元</label>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input type="text" name="comm"   autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-warm" lay-submit lay-filter="add">确定</button>
            </div>
        </div>
    </form>
</div>
<%--换房的弹出表单--%>
<div style="display: none" id="huanfangdiv">
    <form class="layui-form layui-form-pane" action="" lay-filter="msg1">
        <div class="layui-form-item">
            <label class="layui-form-label">可用房间号</label>
            <div class="layui-input-inline">
                <select  id="kyroom" name="newroomid">
                    <option value="" selected="">请选择</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item" style="display:none;">
            <label class="layui-form-label">入住id</label>
            <div class="layui-input-inline">
                <input type="text"  name="ruzhuid" lay-verify="required" readonly autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">时间</label>
            <div class="layui-input-inline">
                <input type="text"  name="time" lay-verify="required" readonly autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">原房间</label>
            <div class="layui-input-inline">
                <input type="text"  name="oldroomid" lay-verify="required" readonly autocomplete="off" class="layui-input" >
            </div>
        </div>

<%--        <div class="layui-form-item">--%>
<%--            <label class="layui-form-label">新房间</label>--%>
<%--            <div class="layui-input-inline">--%>
<%--                <input type="text"  name="newroomid" lay-verify="required" readonly autocomplete="off" class="layui-input" >--%>
<%--            </div>--%>
<%--        </div>--%>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-warm" lay-submit lay-filter="change">确定</button>
            </div>
        </div>
    </form>
</div>
<%--续房的弹出表单--%>
<div style="display: none;" id="order">
    <form class="layui-form layui-form-pane"  lay-filter="add" id="addform">
        <div class="layui-row" width="100%" >
            <!--栅格化 时间部分 -->
            <div class="layui-col-xs5" style="background-color: beige;height: 300px">
                <div class="grid-demo grid-demo-bg1" style="margin-left: 5px;margin-top: 5px;">
                    <div id="test3"></div>
                    <%--                    <input id="test3">--%>
                </div>
            </div>
            <!--栅格化 表单部分 -->
            <div class="layui-col-xs7" style="background-color: beige;height: 300px">
                <%--                <input id="name" name="name" readonly autocomplete="off" class="layui-input">--%>
                <div style="display: none"><input id="d" name="d" readonly autocomplete="off" class="layui-input"></div>
<%--                <div style="display: none"><input id="price"  readonly autocomplete="off" class="layui-input"></div>--%>
                <div class="layui-form-item" style=" margin-top: 5px">
                    <div class="layui-inline">
                        <label class="layui-form-label">续房时间</label>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input id="rzdate" name="rzdate" readonly autocomplete="off" class="layui-input" lay-verify="required">
                        </div>
                        <div class="layui-input-inline" style="width: 100px;display: none">
                            <input id="begintime" name="begintime" readonly autocomplete="off" class="layui-input" lay-verify="required">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input id="leavedate" name="leavedate" readonly autocomplete="off" class="layui-input" lay-verify="required">
                        </div>
                        <div class="layui-input-inline" style="width: 100px;display: none">
                            <input id="endtime" name="endtime" readonly autocomplete="off" class="layui-input" lay-verify="required">
                        </div>
                    </div>
                </div>

                <div class="grid-demo">
                    <div class="layui-form-item" style="display: none">
                        <label class="layui-form-label">入住id</label>
                        <div class="layui-input-inline">
                            <input type="text" id="ruzhuid" name="ruzhuid" lay-verify="required" readonly autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="name" name="name" lay-verify="required" readonly autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">手机号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="tel" name="tel" lay-verify="required" readonly autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">单价</label>
                        <div class="layui-input-inline">
                            <input type="text" id="price" name="tel" lay-verify="required" readonly autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux" style="margin-left: 20px"><span id="tian"></span>天</div>
                    </div>
                    <div class="layui-form-item" style="display:none;">
                        <label class="layui-form-label">数量</label>
                        <div class="layui-input-inline">
                            <input type="text" name="count" readonly lay-verify="required|number" value="1"  autocomplete="off" class="layui-input" id="rcount">
                            <span id="tips" style="font-size: 2px;color: red"></span>
                        </div>
                        <input type="button" value="查询数量" id="search"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">总金额</label>
                        <div class="layui-input-inline" style="width: 80px;">
                            <input id="sum" name="price" readonly autocomplete="off" class="layui-input">

                        </div>
                        <div class="layui-input-inline" style="width: 80px;display: none">
                            <input id="xfprice" name="xfprice" readonly autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline" style="width: 80px;">
                            <button class="layui-btn" lay-submit lay-filter="add">确定</button>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </form>
</div>
</body>
</html>
